package com.cvmars.jianyou.module.activity;

import android.os.Bundle;
import android.widget.Button;
import android.widget.EditText;

import com.cvmars.jianyou.R;
import com.cvmars.jianyou.api.api.Api;
import com.cvmars.jianyou.api.api.HttpUtils;
import com.cvmars.jianyou.api.api.SimpleSubscriber;
import com.cvmars.jianyou.api.model.HttpResult;
import com.cvmars.jianyou.module.base.BaseActivity;
import com.cvmars.jianyou.module.model.EventFindRefresh;
import com.cvmars.jianyou.utils.ToastUtils;

import org.greenrobot.eventbus.EventBus;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class FindCreateTopicActivity extends BaseActivity {

    @BindView(R.id.txt_title)
    EditText txtTitle;
    @BindView(R.id.txt_des)
    EditText txtDes;
    @BindView(R.id.txt_url)
    EditText txtUrl;
    @BindView(R.id.txt_login_btn)
    Button txtLoginBtn;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_find_create_topic);
        ButterKnife.bind(this);
    }

    @OnClick(R.id.txt_login_btn)
    public void onViewClicked() {

        String content = txtTitle.getText().toString();
        String desc = txtTitle.getText().toString();
        String txtUrls = txtUrl.getText().toString();

        HttpUtils.getInstance().toSubscribe(Api.getInstance().postFindTopic(content,desc,txtUrls)
                , new SimpleSubscriber<HttpResult<Object>>() {
                    @Override
                    protected void _onNext(HttpResult<Object> o) {

                        ToastUtils.show("发布成功");

                        txtTitle.setText("");
                        txtDes.setText("");
                        txtUrl.setText("");
                    }

                    @Override
                    protected void _onError(String message) {

                    }
                });

    }
}
